﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Text;

public partial class common_menu_leftnews2 : System.Web.UI.UserControl
{
    private string Whir_U_News_PID = "";
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            GetCategory();
        }
    }


    private void GetCategory()
    {
        //下级栏目
        //string sqlStr = "select * from Whir_Column where parentID = 70  order by sort asc";
        //DataTable dt = Whir.SQLServerDAL.DbHelperSQL.Query(sqlStr).Tables[0];
        //if (dt != null && dt.Rows.Count > 0)
        //{
        //    this.rptList.DataSource = dt;
        //    rptList.DataBind();
        //}

        string sql = "SELECT top 1 * FROM Whir_U_News WHERE  TypeID=60 order by IsTop desc, CreateDate desc";
        DataTable dtAudit = Whir.SQLServerDAL.DbHelperSQL.Query(sql).Tables[0];
        if (dtAudit != null && dtAudit.Rows.Count > 0)
        {
            Whir_U_News_PID = dtAudit.Rows[0]["Whir_U_News_PID"].ToString();
            rptList.DataSource = dtAudit;
            rptList.DataBind();
        }

    }
    protected string GetZtactiveList(int TypeID, int TopNum, int length)
    {
        string str = "";
        if (!string.IsNullOrEmpty(Whir_U_News_PID))
        {
            str="and Whir_U_News_PID<>" + Whir_U_News_PID;
        }
        string sql = "select top " + TopNum + " * from Whir_U_News where (TypeID=" + TypeID + " or TypeID in (select ColumnID from Whir_Column where ParentId=" + TypeID + ")) " + str + " order by  newid()";
        string mode = "ztactive";

        System.Text.StringBuilder sb = new StringBuilder();
        System.Data.DataTable dt = Whir.SQLServerDAL.DbHelperSQL.Query(sql).Tables[0];
        if (dt != null && dt.Rows.Count > 0)
        {
            foreach (System.Data.DataRow dr in dt.Rows)
            {
                string title = dr["Title"].ToString();
                string id = dr["Whir_U_News_PID"].ToString();
                string _TypeID = dr["TypeID"].ToString();
                sb.AppendFormat("<li><a title=\"{0}\"  href=\"news_info.aspx?id={1}&mode=baiy&cid={2}\">" + Whir.Common.WebHelper.StringHelper.CutString(dr["Title"].ToString(), length) + "</a></li>", title, id, _TypeID);
            }
        }

        return sb.ToString();
    }
}
